#include <iostream>
#include <queue>
#include <cstdio>
using namespace std;
bool reach[1010][1010];
int x,y,n;
typedef struct point
{
    int x;
    int y;
    point(int a,int b)
    {
        x=a;
        y=b;
    }
}point;
int f()
{
    int count=1,tx,ty,p=0;
    queue<point> q[2];
    q[p].push(point(500,500));
    while(1)
    {
        tx=q[p].front().x;
        ty=q[p].front().y;
        q[p].pop();
        if(tx+1<=1000&&reach[tx+1][ty])
        {
            if(tx+1==x&&ty==y) return count;
            q[(p+1)%2].push(point(tx+1,ty));
            reach[tx+1][ty]=false;
        }
        if(ty+1<=1000&&reach[tx][ty+1])
        {
            if(tx==x&&ty+1==y) return count;
            q[(p+1)%2].push(point(tx,ty+1));
            reach[tx][ty+1]=false;
        }
        if(tx-1>=0&&reach[tx-1][ty])
        {
            if(tx-1==x&&ty==y) return count;
            q[(p+1)%2].push(point(tx-1,ty));
            reach[tx-1][ty]=false;
        }
        if(ty-1>=0&&reach[tx][ty-1])
        {
            if(tx==x&&ty-1==y) return count;
            q[(p+1)%2].push(point(tx,ty-1));
            reach[tx][ty-1]=false;
        }
        if(q[p].empty())
        {
            count++;
            p=(p+1)%2;
        }
    }
}
int main()
{
    int i,j;
    fill(reach[0],reach[0]+1010*1010,1);
    cin>>x>>y>>n;
    x+=500;
    y+=500;
    while(n--)
    {
        scanf("%d%d",&i,&j);
        reach[i+500][j+500]=0;
    }
    cout<<f()<<endl;
    return 0;
}


